package cn.honglian.system.service.impl;


import cn.honglian.basic.service.impl.BaseServiceImpl;
import cn.honglian.system.domain.Systemdictionarydetail;
import cn.honglian.system.domain.Systemdictionarytype;
import cn.honglian.system.mapper.SystemdictionarydetailMapper;
import cn.honglian.system.mapper.SystemdictionarytypeMapper;
import cn.honglian.system.service.SystemdictionarytypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SystemdictionarytypeServiceImpl extends BaseServiceImpl<Systemdictionarytype> implements SystemdictionarytypeService {

    @Autowired
    private SystemdictionarytypeMapper mapper;

    @Autowired
    private SystemdictionarydetailMapper systemdictionarydetailMapper;

    @Override
    public void delete(Long id) {

        List<Systemdictionarydetail> all = systemdictionarydetailMapper.findAll();
        for (Systemdictionarydetail detail :all) {
                if (detail.getTypesId()==id){
                    systemdictionarydetailMapper.delete(detail.getId());
                }
        }
        mapper.delete(id);
    }
    @Override
    public void batchDelete(List<Long> ids) {
        List<Systemdictionarydetail> all = systemdictionarydetailMapper.findAll();
        for (Systemdictionarydetail detail :all) {
            for (Long id:ids)
                if (detail.getTypesId()==id){
                    systemdictionarydetailMapper.delete(detail.getId());
                }
        }
        mapper.batchDelete(ids);
    }
}
